package com.cty;
/*
*生成xml文件
* 用dom4j框架比较麻烦，这里就用io输入比较简单
* */

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class xml02 {
    public static void main(String[] args) {
        StringBuilder sb=new StringBuilder();
        sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n");
        sb.append("<people>");
        sb.append("\t<name>").append("jack").append("</name>\r\n");
        sb.append("\t<age>").append("18").append("</age>\r\n");
        sb.append("\t<sex>").append("男").append("</sex>\r\n");
        sb.append("</people>");

        try (BufferedWriter bw = new BufferedWriter(new FileWriter("src/people.xml"));){
            bw.write(sb.toString());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        System.out.println("写入成功");
    }
}
